
const Service = require('egg').Service;

class DesignService extends Service {

    async createDesign(data) {
        const ctx = this.ctx;

        console.log(ctx.state.user);
        
        return new Promise(async (resolve, reject) => {
            ctx.model.Design({
                ...data,
                creator: ctx.state.user.id
            }).save((err, data) => {
                if (err) {
                    console.log(err);
                    reject(err);
                    return
                }
                resolve(data)
            })
        })
    }
}

module.exports = DesignService;
